<?php

class Cache {
	static private $cache_arr = array();
	static public function & getInstance($cache_name = "cache_options")
	{
		
		$key = 'cache_'.$cache_name;
		if(!isset(self::$cache_arr[$key]) || is_null(self::$cache_arr[$key])) {
			$options = Context::getConfig($cache_name);
			$cacheType = $options["cache_type"]; 
			
			switch ($cacheType) {
				case 'memcache' :
					$cache = new MyMemcache($options);
					break;
				case 'db' :
					$cache = new DbCache($options);
					break;
				default:
					$cache = Null;
					break;
			} 
			self::$cache_arr[$key] = $cache; 
		}
		return self::$cache_arr[$key];
	}
}
